<template>
	<view class="markerCluster" @tap="back">
		<view class="" @tap.stop>
			<view class="list">
				<view @click="handeClick(item)" class="listItem" v-for="(item,index) in data.list" :key="index">
					<!-- 	<view class="top">
						<text></text>
						<text>已上架</text>
					</view> -->
					<view class="goods">
						<view :class="item.productType.value == 'DEMAND'?'viewRed':'viewBlue'">
							<text>{{item.productType.name}}</text>
							<image :src="data.httpUrl+'/app/file/viewFile?fileId='+item.attachmentIds[0]"
								mode="aspectFill"></image>
						</view>
						<view class="right">
							{{item.title}}
							<text>{{item.content}}</text>
							<view class="priceText">
								<text>{{item.price.split('.')[0]}}</text>
								<text>.{{item.price.split('.')[1]}}</text>
							</view>
						</view>
						<!-- <text>{{item.distance}}km</text> -->
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script setup lang="ts">
	import { reactive } from 'vue';
	const data = reactive<any>({
		httpUrl: getApp().globalData.baseUrl,
		list: []
	})
	uni.$off('markerCluster');
	uni.$on('markerCluster', (list) => {
		data.list = list;
	})
	const back = () => {
		uni.navigateBack()
	}
	const handeClick = (item) => {
		if (item.productType.value == 'DEMAND') {
			uni.navigateTo({
				url: '/pages/requirementDetails/index?id=' + item.idd
			})
		} else {
			uni.navigateTo({
				url: '/pages/lifestyleProducts/index?id=' + item.idd + '&productType=' + item.productType.value
			})
		}

	}
</script>

<style lang="scss">
	page {
		background: transparent;
	}

	.markerCluster {
		position: fixed;
		left: 0;
		top: 0;
		bottom: 0;
		right: 0;
		background: rgba(0, 0, 0, .1);
		display: flex;
		align-items: flex-end;
		justify-content: center;
		flex-direction: column;

		>view {
			flex: 1;
			overflow: auto;
			background: #fff;
			padding: 100rpx 0;
			display: flex;
			flex-direction: column;
			width: 70%;
		}
	}

	.list {
		width: 100%;
		overflow: auto;
		flex: 1;

		>view:nth-of-type(1) {
			margin-top: 0;
		}
	}

	.listItem {
		padding: 20rpx;
		background: #fff;
		border-radius: 16rpx;
		
		>.top {
			display: flex;
			align-items: center;
			justify-content: space-between;
			color: #595959;

			text {
				color: #FF8C00;
			}

			padding: 20rpx 0;
		}

		>.goods {
			display: flex;
			align-items: center;
			
			// >text {
			// 	font-size: 22rpx;
			// 	color: #595959;
			// }
			
			.viewRed {
				position: relative;
				width: 140rpx;
				height: 140rpx;
				border-radius: 24rpx;
				background: #ccc;
				margin-right: 16rpx;
			
				text {
					width: 72rpx;
					line-height: 40rpx;
					text-align: center;
					font-size: 20rpx;
					color: #FFF5E2;
					display: inline-block;
					position: absolute;
					left: 0;
					top: 0;
					z-index: 5;
					box-shadow: inset -1rpx -1rpx 4rpx 0rpx rgba(255, 234, 160, 0.3);
					border-radius: 24rpx 0 24rpx 0;
					background: linear-gradient(223deg, #ffb3b3 0%, #ffb3b3 100%);
				}
			
				image {
					width: 100%;
					height: 100%;
					border-radius: 24rpx;
				}
			}
			
			.viewBlue {
				position: relative;
				width: 140rpx;
				height: 140rpx;
				border-radius: 24rpx;
				background: #ccc;
				margin-right: 16rpx;
			
				text {
					width: 72rpx;
					line-height: 40rpx;
					text-align: center;
					font-size: 20rpx;
					color: #FFF5E2;
					display: inline-block;
					position: absolute;
					left: 0;
					top: 0;
					z-index: 5;
					box-shadow: inset -1rpx -1rpx 4rpx 0rpx rgba(255, 234, 160, 0.3);
					border-radius: 24rpx 0 24rpx 0;
					background: linear-gradient(223deg, #66c2ff 0%, #66c2ff 100%);
				}
			
				image {
					width: 100%;
					height: 100%;
					border-radius: 24rpx;
				}
			}

			.right {
				flex: 1;
				width: 0;
				font-size: 28rpx;
				display: flex;
				flex-direction: column;

				>text {
					color: #595959;
					font-size: 24rpx;
					margin-top: 8rpx;
				}
			}
		}

		>.bot {
			margin-top: 24rpx;
			border-top: 2rpx solid #F4F6FA;
			display: flex;
			justify-content: flex-end;
			padding: 24rpx 0;

			text {
				width: 140rpx;
				line-height: 64rpx;
				text-align: center;
				border-radius: 32rpx;
				margin-left: 16rpx;
			}

			text:nth-of-type(1) {
				color: #595959;
				border: 2rpx solid #D9D9D9;
			}

			text:nth-of-type(2) {
				color: #6B64D3;
				border: 2rpx solid #6B64D3;
			}

		}
	}
</style>